#include <stdio.h>

int main(void)
{
    _Bool isPrime, retry;

    unsigned long num;
    unsigned long div;

    do {

        printf("Please enter a integer for analysis; ");
        printf("Enter q to quit.\n");

        if (retry = scanf("%ld", &num) == 1) {
            for (div = 2, isPrime = 1; div * div <= num; ++div) {
                if (num % div == 0) {
                    isPrime = 0;

                    if (div * div != num) {
                        printf("%lu is divisible by %lu and %lu.\n", num, div, num / div);
                    } else {
                        printf("%lu is divisible by %lu.\n", num, div);
                    }
                }
            }

            if (isPrime) {
                printf("%lu is prime.\n", num);
            }

        }
    } while (retry);

   printf("Bye.\n");

    return 0;
}
